package com.leather.admin.controller;

import com.leather.admin.feignclient.UserClient;
import com.leather.common.entity.Activity;
import com.leather.common.result.Result;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/admin/client")
public class ClientController {

    @Autowired
    private UserClient userClient;

    @RequiresPermissions("admin:client:index")
    @GetMapping("/index")
    public String index() {
        return "client/index";
    }

    @RequiresPermissions("admin:client:index")
    @GetMapping("/list")
    @ResponseBody
    public Object list(
            @RequestParam(required = false, defaultValue = "0") int offset,
            @RequestParam(required = false, defaultValue = "10") int limit,
            @RequestParam(required = false, defaultValue = "asc") String order,
            @RequestParam(required = false, defaultValue = "") String search
    ) {
        return userClient.list(offset, limit, order, search);
    }

    @ResponseBody
    @PostMapping("/frozenuser")
    public Result fronzenUser(@RequestParam("id") int id) {
        return userClient.frozenUser(id);
    }


    @ResponseBody
    @PostMapping("/unfrozenuser")
    public Result unFronzenUser(@RequestParam("id") int id) {
        return userClient.unFrozenUser(id);
    }

}
